clc 
close all
clear all
%%PRKS
pdr95_pro_rd1 = GetStableRegionConcurrentTransmitters('PRKS95_concurrency_rd1.txt');
pdr95_pro_rd2 = GetStableRegionConcurrentTransmitters('PRKS95_concurrency_rd2.txt');
pdr95_pro_rd3 = GetStableRegionConcurrentTransmitters('PRKS95_concurrency_rd3.txt');
pdr95_pro_rd4 = GetStableRegionConcurrentTransmitters('PRKS95_concurrency_rd4.txt');
pdr95_pro_rd5 = GetStableRegionConcurrentTransmitters('PRKS95_concurrency_rd5.txt');
concurrenttransmitters_pro_95 = [pdr95_pro_rd1; pdr95_pro_rd2;pdr95_pro_rd3;pdr95_pro_rd4;pdr95_pro_rd5];

pdr90_pro_rd1 = GetStableRegionConcurrentTransmitters('PRKS90_concurrency_rd1.txt');
pdr90_pro_rd2 = GetStableRegionConcurrentTransmitters('PRKS90_concurrency_rd2.txt');
pdr90_pro_rd3 = GetStableRegionConcurrentTransmitters('PRKS90_concurrency_rd3.txt');
pdr90_pro_rd4 = GetStableRegionConcurrentTransmitters('PRKS90_concurrency_rd4.txt');
pdr90_pro_rd5 = GetStableRegionConcurrentTransmitters('PRKS90_concurrency_rd5.txt');
concurrenttransmitters_pro_90 = [pdr90_pro_rd1; pdr90_pro_rd2;pdr90_pro_rd3;pdr90_pro_rd4;pdr90_pro_rd5];

pdr80_pro_rd1 = GetStableRegionConcurrentTransmitters('PRKS80_concurrency_rd1.txt');
pdr80_pro_rd2 = GetStableRegionConcurrentTransmitters('PRKS80_concurrency_rd2.txt');
pdr80_pro_rd3 = GetStableRegionConcurrentTransmitters('PRKS80_concurrency_rd3.txt');
pdr80_pro_rd4 = GetStableRegionConcurrentTransmitters('PRKS80_concurrency_rd4.txt');
pdr80_pro_rd5 = GetStableRegionConcurrentTransmitters('PRKS80_concurrency_rd5.txt');
concurrenttransmitters_pro_80 = [pdr80_pro_rd1; pdr80_pro_rd2;pdr80_pro_rd3;pdr80_pro_rd4;pdr80_pro_rd5];

pdr70_pro_rd1 = GetStableRegionConcurrentTransmitters('PRKS70_concurrency_rd1.txt');
pdr70_pro_rd2 = GetStableRegionConcurrentTransmitters('PRKS70_concurrency_rd2.txt');
pdr70_pro_rd3 = GetStableRegionConcurrentTransmitters('PRKS70_concurrency_rd3.txt');
pdr70_pro_rd4 = GetStableRegionConcurrentTransmitters('PRKS70_concurrency_rd4.txt');
pdr70_pro_rd5 = GetStableRegionConcurrentTransmitters('PRKS70_concurrency_rd5.txt');
concurrenttransmitters_pro_70 = [pdr70_pro_rd1; pdr70_pro_rd2;pdr70_pro_rd3;pdr70_pro_rd4;pdr70_pro_rd5];

%%PRKS_L
pdr95_nopro_rd1 = GetStableRegionConcurrentTransmitters('PRKS_L95_concurrency_rd1.txt');
pdr95_nopro_rd2 = GetStableRegionConcurrentTransmitters('PRKS_L95_concurrency_rd2.txt');
pdr95_nopro_rd3 = GetStableRegionConcurrentTransmitters('PRKS_L95_concurrency_rd3.txt');
pdr95_nopro_rd4 = GetStableRegionConcurrentTransmitters('PRKS_L95_concurrency_rd4.txt');
pdr95_nopro_rd5 = GetStableRegionConcurrentTransmitters('PRKS_L95_concurrency_rd5.txt');
concurrenttransmitters_nopro_95 = [pdr95_nopro_rd1; pdr95_nopro_rd2;pdr95_nopro_rd3;pdr95_nopro_rd4;pdr95_nopro_rd5];

pdr90_nopro_rd1 = GetStableRegionConcurrentTransmitters('PRKS_L90_concurrency_rd1.txt');
pdr90_nopro_rd2 = GetStableRegionConcurrentTransmitters('PRKS_L90_concurrency_rd2.txt');
pdr90_nopro_rd3 = GetStableRegionConcurrentTransmitters('PRKS_L90_concurrency_rd3.txt');
pdr90_nopro_rd4 = GetStableRegionConcurrentTransmitters('PRKS_L90_concurrency_rd4.txt');
pdr90_nopro_rd5 = GetStableRegionConcurrentTransmitters('PRKS_L90_concurrency_rd5.txt');
concurrenttransmitters_nopro_90 = [pdr90_nopro_rd1; pdr90_nopro_rd2;pdr90_nopro_rd3;pdr90_nopro_rd4;pdr90_nopro_rd5];

pdr80_nopro_rd1 = GetStableRegionConcurrentTransmitters('PRKS_L80_concurrency_rd1.txt');
pdr80_nopro_rd2 = GetStableRegionConcurrentTransmitters('PRKS_L80_concurrency_rd2.txt');
pdr80_nopro_rd3 = GetStableRegionConcurrentTransmitters('PRKS_L80_concurrency_rd3.txt');
pdr80_nopro_rd4 = GetStableRegionConcurrentTransmitters('PRKS_L80_concurrency_rd4.txt');
pdr80_nopro_rd5 = GetStableRegionConcurrentTransmitters('PRKS_L80_concurrency_rd5.txt');
concurrenttransmitters_nopro_80 = [pdr80_nopro_rd1; pdr80_nopro_rd2;pdr80_nopro_rd3;pdr80_nopro_rd4;pdr80_nopro_rd5];

pdr70_nopro_rd1 = GetStableRegionConcurrentTransmitters('PRKS_L70_concurrency_rd1.txt');
pdr70_nopro_rd2 = GetStableRegionConcurrentTransmitters('PRKS_L70_concurrency_rd2.txt');
pdr70_nopro_rd3 = GetStableRegionConcurrentTransmitters('PRKS_L70_concurrency_rd3.txt');
pdr70_nopro_rd4 = GetStableRegionConcurrentTransmitters('PRKS_L70_concurrency_rd4.txt');
pdr70_nopro_rd5 = GetStableRegionConcurrentTransmitters('PRKS_L70_concurrency_rd5.txt');
concurrenttransmitters_nopro_70 = [pdr70_nopro_rd1; pdr70_nopro_rd2;pdr70_nopro_rd3;pdr70_nopro_rd4;pdr70_nopro_rd5];

%%PRKS_R
pdr95_p1_rd1 = GetStableRegionConcurrentTransmitters('PRKS_R95_concurrency_rd1.txt');
pdr95_p1_rd2 = GetStableRegionConcurrentTransmitters('PRKS_R95_concurrency_rd2.txt');
pdr95_p1_rd3 = GetStableRegionConcurrentTransmitters('PRKS_R95_concurrency_rd3.txt');
pdr95_p1_rd4 = GetStableRegionConcurrentTransmitters('PRKS_R95_concurrency_rd4.txt');
pdr95_p1_rd5 = GetStableRegionConcurrentTransmitters('PRKS_R95_concurrency_rd5.txt');
concurrenttransmitters_p1_95 = [pdr95_p1_rd1; pdr95_p1_rd2;pdr95_p1_rd3;pdr95_p1_rd4;pdr95_p1_rd5];

pdr90_p1_rd1 = GetStableRegionConcurrentTransmitters('PRKS_R90_concurrency_rd1.txt');
pdr90_p1_rd2 = GetStableRegionConcurrentTransmitters('PRKS_R90_concurrency_rd2.txt');
pdr90_p1_rd3 = GetStableRegionConcurrentTransmitters('PRKS_R90_concurrency_rd3.txt');
pdr90_p1_rd4 = GetStableRegionConcurrentTransmitters('PRKS_R90_concurrency_rd4.txt');
pdr90_p1_rd5 = GetStableRegionConcurrentTransmitters('PRKS_R90_concurrency_rd5.txt');
concurrenttransmitters_p1_90 = [pdr90_p1_rd1; pdr90_p1_rd2;pdr90_p1_rd3;pdr90_p1_rd4;pdr90_p1_rd5];

pdr80_p1_rd1 = GetStableRegionConcurrentTransmitters('PRKS_R80_concurrency_rd1.txt');
pdr80_p1_rd2 = GetStableRegionConcurrentTransmitters('PRKS_R80_concurrency_rd2.txt');
pdr80_p1_rd3 = GetStableRegionConcurrentTransmitters('PRKS_R80_concurrency_rd3.txt');
pdr80_p1_rd4 = GetStableRegionConcurrentTransmitters('PRKS_R80_concurrency_rd4.txt');
pdr80_p1_rd5 = GetStableRegionConcurrentTransmitters('PRKS_R80_concurrency_rd5.txt');
concurrenttransmitters_p1_80 = [pdr80_p1_rd1; pdr80_p1_rd2;pdr80_p1_rd3;pdr80_p1_rd4;pdr80_p1_rd5];

pdr70_p1_rd1 = GetStableRegionConcurrentTransmitters('PRKS_R70_concurrency_rd1.txt');
pdr70_p1_rd2 = GetStableRegionConcurrentTransmitters('PRKS_R70_concurrency_rd2.txt');
pdr70_p1_rd3 = GetStableRegionConcurrentTransmitters('PRKS_R70_concurrency_rd3.txt');
pdr70_p1_rd4 = GetStableRegionConcurrentTransmitters('PRKS_R70_concurrency_rd4.txt');
pdr70_p1_rd5 = GetStableRegionConcurrentTransmitters('PRKS_R70_concurrency_rd5.txt');
concurrenttransmitters_p1_70 = [pdr70_p1_rd1; pdr70_p1_rd2;pdr70_p1_rd3;pdr70_p1_rd4;pdr70_p1_rd5];

%%PRKS_RI
pdr95_p2_rd1 = GetStableRegionConcurrentTransmitters('PRKS_RI95_concurrency_rd1.txt');
pdr95_p2_rd2 = GetStableRegionConcurrentTransmitters('PRKS_RI95_concurrency_rd2.txt');
pdr95_p2_rd3 = GetStableRegionConcurrentTransmitters('PRKS_RI95_concurrency_rd3.txt');
pdr95_p2_rd4 = GetStableRegionConcurrentTransmitters('PRKS_RI95_concurrency_rd4.txt');
pdr95_p2_rd5 = GetStableRegionConcurrentTransmitters('PRKS_RI95_concurrency_rd5.txt');
concurrenttransmitters_p2_95 = [pdr95_p2_rd1; pdr95_p2_rd2;pdr95_p2_rd3;pdr95_p2_rd4;pdr95_p2_rd5];

pdr90_p2_rd1 = GetStableRegionConcurrentTransmitters('PRKS_RI90_concurrency_rd1.txt');
pdr90_p2_rd2 = GetStableRegionConcurrentTransmitters('PRKS_RI90_concurrency_rd2.txt');
pdr90_p2_rd3 = GetStableRegionConcurrentTransmitters('PRKS_RI90_concurrency_rd3.txt');
pdr90_p2_rd4 = GetStableRegionConcurrentTransmitters('PRKS_RI90_concurrency_rd4.txt');
pdr90_p2_rd5 = GetStableRegionConcurrentTransmitters('PRKS_RI90_concurrency_rd5.txt');
concurrenttransmitters_p2_90 = [pdr90_p2_rd1; pdr90_p2_rd2;pdr90_p2_rd3;pdr90_p2_rd4;pdr90_p2_rd5];

pdr80_p2_rd1 = GetStableRegionConcurrentTransmitters('PRKS_RI80_concurrency_rd1.txt');
pdr80_p2_rd2 = GetStableRegionConcurrentTransmitters('PRKS_RI80_concurrency_rd2.txt');
pdr80_p2_rd3 = GetStableRegionConcurrentTransmitters('PRKS_RI80_concurrency_rd3.txt');
pdr80_p2_rd4 = GetStableRegionConcurrentTransmitters('PRKS_RI80_concurrency_rd4.txt');
pdr80_p2_rd5 = GetStableRegionConcurrentTransmitters('PRKS_RI80_concurrency_rd5.txt');
concurrenttransmitters_p2_80 = [pdr80_p2_rd1; pdr80_p2_rd2;pdr80_p2_rd3;pdr80_p2_rd4;pdr80_p2_rd5];

pdr70_p2_rd1 = GetStableRegionConcurrentTransmitters('PRKS_RI70_concurrency_rd1.txt');
pdr70_p2_rd2 = GetStableRegionConcurrentTransmitters('PRKS_RI70_concurrency_rd2.txt');
pdr70_p2_rd3 = GetStableRegionConcurrentTransmitters('PRKS_RI70_concurrency_rd3.txt');
pdr70_p2_rd4 = GetStableRegionConcurrentTransmitters('PRKS_RI70_concurrency_rd4.txt');
pdr70_p2_rd5 = GetStableRegionConcurrentTransmitters('PRKS_RI70_concurrency_rd5.txt');
concurrenttransmitters_p2_70 = [pdr70_p2_rd1; pdr70_p2_rd2;pdr70_p2_rd3;pdr70_p2_rd4;pdr70_p2_rd5];


%load iOrder_73.mat
load small_70.mat
%load ns3_70.mat
iOrder70 = result(:,2);
%load iOrder_83.mat
load small_80.mat
%load ns3_80.mat
iOrder80 = result(:,2);
%load iOrder_93.mat
%load ns3_90.mat
load small_90.mat
iOrder90 = result(:,2);
%load iOrder_98.mat 
%load ns3_95.mat
load small_95.mat
iOrder95 = result(:,2);


ALPHA=0.05;

MEAN = zeros(4,3);
Error_MEAN = zeros(4,3);
MEAN(1,1) = mean(concurrenttransmitters_pro_70);
MEAN(1,2) = mean(concurrenttransmitters_p1_70);
%MEAN(1,3) = mean(concurrenttransmitters_p2_70);
MEAN(1,3) = mean(concurrenttransmitters_nopro_70);
%MEAN(1,5) = mean(iOrder70);

Error_MEAN(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_70) / sqrt(size(concurrenttransmitters_pro_70, 1));
Error_MEAN(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p1_70) / sqrt(size(concurrenttransmitters_p1_70, 1));
%Error_MEAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p2_70) / sqrt(size(concurrenttransmitters_p2_70, 1));
Error_MEAN(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_nopro_70) / sqrt(size(concurrenttransmitters_nopro_70, 1));
%Error_MEAN(1,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder70) / sqrt(size(iOrder70, 1));
%MEAN(1,5) = mean(concurrenttransmitters_rid_70(:,3));
MEAN(2,1) = mean(concurrenttransmitters_pro_80);
MEAN(2,2) = mean(concurrenttransmitters_p1_80);
%MEAN(2,3) = mean(concurrenttransmitters_p2_80);
MEAN(2,3) = mean(concurrenttransmitters_nopro_80);
%MEAN(2,5) = mean(iOrder80);
Error_MEAN(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_80) / sqrt(size(concurrenttransmitters_pro_80, 1));
Error_MEAN(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p1_80) / sqrt(size(concurrenttransmitters_p1_80, 1));
%Error_MEAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p2_80) / sqrt(size(concurrenttransmitters_p2_80, 1));
Error_MEAN(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_nopro_80) / sqrt(size(concurrenttransmitters_nopro_80, 1));
%Error_MEAN(2,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder80) / sqrt(size(iOrder80, 1));
%MEAN(2,5) = mean(concurrenttransmitters_rid_80(:,3));
MEAN(3,1) = mean(concurrenttransmitters_pro_90);
MEAN(3,2) = mean(concurrenttransmitters_p1_90);
%MEAN(3,3) = mean(concurrenttransmitters_p2_90);
MEAN(3,3) = mean(concurrenttransmitters_nopro_90);
%MEAN(3,5) = mean(iOrder90);
Error_MEAN(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_90) / sqrt(size(concurrenttransmitters_pro_90, 1));
Error_MEAN(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p1_90) / sqrt(size(concurrenttransmitters_p1_90, 1));
%Error_MEAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p2_90) / sqrt(size(concurrenttransmitters_p2_90, 1));
Error_MEAN(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_nopro_90) / sqrt(size(concurrenttransmitters_nopro_90, 1));
%Error_MEAN(3,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder90) / sqrt(size(iOrder90, 1));
%MEAN(3,5) = mean(concurrenttransmitters_rid_90(:,3));
MEAN(4,1) = mean(concurrenttransmitters_pro_95);
MEAN(4,2) = mean(concurrenttransmitters_p1_95);
%MEAN(4,3) = mean(concurrenttransmitters_p2_95);
MEAN(4,3) = mean(concurrenttransmitters_nopro_95);
%MEAN(4,5) = mean(iOrder95);
Error_MEAN(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_95) / sqrt(size(concurrenttransmitters_pro_95, 1));
Error_MEAN(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p1_95) / sqrt(size(concurrenttransmitters_p1_95, 1));
%Error_MEAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_p2_95) / sqrt(size(concurrenttransmitters_p2_95, 1));
Error_MEAN(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_nopro_95) / sqrt(size(concurrenttransmitters_nopro_95, 1));
%Error_MEAN(4,5) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder95) / sqrt(size(iOrder95, 1));
%MEAN(4,5) = mean(concurrenttransmitters_rid_95(:,3));
MEAN
Error_MEAN
figure;
%handle = barweb(MEAN, Error_MEAN,1, ['70%';'80%';'90%';'95%'], [], ['PDR requirement'], ['Mean concurrency'], [1 1 1; 0.6 0.6 0.6; 0.15 0.15 0.15; 0 0 0]);
handle = barweb(MEAN, Error_MEAN,1, ['70%';'80%';'90%';'95%'], [], ['PDR requirement'], ['Mean concurrency'],jet);
handle.legend =legend ('PRKS','PRKS-R','PRKS-L','orientation','horizontal');
ylim([3 8]);
%set(gca,'fontsize',60);
box on
grid on;
maximize ();
%saveas(gcf, 'concurrenttransmitters_all_prks_versions_TR.jpg');
%saveas(gcf, 'concurrenttransmitters_all_prks_versions_TR.eps');
%saveas(gcf, 'concurrenttransmitters_all_prks_versions_TR.fig');


%%================================PRKS and iOrder only============================
MEAN = zeros(2,2);
Error_MEAN = zeros(4,2);
MEAN(1,1) = mean(concurrenttransmitters_pro_70);
MEAN(1,2) = mean(iOrder70);

Error_MEAN(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_70) / sqrt(size(concurrenttransmitters_pro_70, 1));
Error_MEAN(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder70) / sqrt(size(iOrder70, 1));
%MEAN(1,5) = mean(concurrenttransmitters_rid_70(:,3));
MEAN(2,1) = mean(concurrenttransmitters_pro_80);
MEAN(2,2) = mean(iOrder80);
Error_MEAN(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_80) / sqrt(size(concurrenttransmitters_pro_80, 1));
Error_MEAN(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder80) / sqrt(size(iOrder80, 1));
%MEAN(2,5) = mean(concurrenttransmitters_rid_80(:,3));
MEAN(3,1) = mean(concurrenttransmitters_pro_90);
MEAN(3,2) = mean(iOrder90);
Error_MEAN(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_90) / sqrt(size(concurrenttransmitters_pro_90, 1));
Error_MEAN(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder90) / sqrt(size(iOrder90, 1));
%MEAN(3,5) = mean(concurrenttransmitters_rid_90(:,3));
MEAN(4,1) = mean(concurrenttransmitters_pro_95);
MEAN(4,2) = mean(iOrder95);
Error_MEAN(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(concurrenttransmitters_pro_95) / sqrt(size(concurrenttransmitters_pro_95, 1));
Error_MEAN(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(iOrder95) / sqrt(size(iOrder95, 1));
%MEAN(4,5) = mean(concurrenttransmitters_rid_95(:,3));
MEAN
Error_MEAN
figure;
%handle = barweb(MEAN, Error_MEAN,1, ['70%';'80%';'90%';'95%'], [], ['PDR requirement'], ['Mean concurrency'], [1 1 1; 0.6 0.6 0.6; 0.15 0.15 0.15; 0 0 0]);
handle = barweb(MEAN, Error_MEAN,1, ['70%';'80%';'90%';'95%'], [], ['PDR requirement'], ['Mean concurrency'],jet);
handle.legend =legend ('PRKS','iOrder','orientation','horizontal');
ylim([4,9]);
set(gca,'fontsize',60);
box on
maximize ();




